import maya.cmds as cmds

def arclgth ():

	sel = cmds.ls (sl = 1)[0]

	crv_info = cmds.arclen (sel, ch = 1)
	crv_info = cmds.rename (crv_info, sel+'_info')

	return crv_info



def doit ():

	jnts = cmds.ls (sl = 1)[:-1]
	crv = cmds.ls (sl = 1, tl =1)

	#Create Curve Info Node

	cmds.select (crv)
	crv_info = arclgth ()

	#Create Multiply Divide Node

	calc = cmds.createNode ('multiplyDivide')
	cmds.setAttr (calc + '.op',2)

	#Connect to Multiply Divide Node

	cmds.connectAttr (crv_info + '.arcLength',calc + '.input1X')
	cmds.setAttr (calc + '.input2X',cmds.getAttr(crv_info + '.arcLength'))

	for obj in jnts:

		cmds.connectAttr (calc + '.outputX', obj + '.scaleX')
